package ycl.scheduled.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import ycl.scheduled.common.base.mapper.BaseDao;
import ycl.scheduled.entity.SysUser;

/**
 * <p>
 * 用户表 Mapper 接口
 * </p>
 *
 * @author ycl
 * @since 2022-01-20 00:04:45
 */
@Mapper
public interface SysUserMapper extends BaseDao<SysUser> {

	/**
	 * 根据微信id查询用户
	 *
	 * @param wechatId 用户微信id
	 * @return 用户
	 */
	@Select("select * from sys_user where wechat_id = #{wechatId} limit 1")
	SysUser selectByWechatId(@Param("wechatId") String wechatId);

	@Select("select count(*) > 0 from sys_user where wechat_id = #{wechatId} limit 1")
	boolean existByWechatId(@Param("wechatId") String wechatId);

	@Select("select count(*) > 0 from sys_user where invitation_code = #{code} limit 1")
	boolean existByInvitationCode(String code);

	/**
	 * 用户登录
	 * @param id 用户id
	 * @param token token
	 * @param ip ip
	 */
	void login(@Param("id") Long id, @Param("token") String token, @Param("ip") String ip);
}
